package com.ruoyi.disease.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.disease.mapper.FirefighterDiseaseMapper;
import com.ruoyi.disease.domain.FirefighterDisease;
import com.ruoyi.disease.service.IFirefighterDiseaseService;

/**
 * 健康情况Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class FirefighterDiseaseServiceImpl implements IFirefighterDiseaseService
{
    @Autowired
    private FirefighterDiseaseMapper firefighterDiseaseMapper;
    @Autowired
    private IFirefighterInfoService iFirefighterInfoService;
    /**
     * 查询健康情况
     *
     * @param id 健康情况主键
     * @return 健康情况
     */
    @Override
    public FirefighterDisease selectFirefighterDiseaseById(Long id)
    {
        return firefighterDiseaseMapper.selectFirefighterDiseaseById(id);
    }

    /**
     * 查询健康情况列表
     *
     * @param firefighterDisease 健康情况
     * @return 健康情况
     */
    @Override
    public List<FirefighterDisease> selectFirefighterDiseaseList(FirefighterDisease firefighterDisease)
    {
        return firefighterDiseaseMapper.selectFirefighterDiseaseList(firefighterDisease);
    }

    /**
     * 新增健康情况
     *
     * @param firefighterDisease 健康情况
     * @return 结果
     */
    @Override
    public int insertFirefighterDisease(FirefighterDisease firefighterDisease)
    {
        FirefighterInfo firefighterInfo1 = new FirefighterInfo();
        firefighterInfo1.setIdCardNumber(firefighterDisease.getFirefighterIdCard());
        FirefighterInfo firefighterInfo= iFirefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo1);
        firefighterDisease.setFirefighterId(firefighterInfo.getUserId());
        firefighterDisease.setCreateTime(DateUtils.getNowDate());
        return firefighterDiseaseMapper.insertFirefighterDisease(firefighterDisease);
    }

    /**
     * 修改健康情况
     *
     * @param firefighterDisease 健康情况
     * @return 结果
     */
    @Override
    public int updateFirefighterDisease(FirefighterDisease firefighterDisease)
    {
        firefighterDisease.setUpdateTime(DateUtils.getNowDate());
        return firefighterDiseaseMapper.updateFirefighterDisease(firefighterDisease);
    }

    /**
     * 批量删除健康情况
     *
     * @param ids 需要删除的健康情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterDiseaseByIds(Long[] ids)
    {
        return firefighterDiseaseMapper.deleteFirefighterDiseaseByIds(ids);
    }

    /**
     * 删除健康情况信息
     *
     * @param id 健康情况主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterDiseaseById(Long id)
    {
        return firefighterDiseaseMapper.deleteFirefighterDiseaseById(id);
    }

    @Override
    public void deleteFirefighterDiseaseById1(Long userId) {
         firefighterDiseaseMapper.deleteFirefighterDiseaseByIds1(userId);
    }
}
